package com.igeek.boot.controller;

import com.igeek.boot.entity.Orders;
import com.igeek.boot.result.Result;
import com.igeek.boot.service.OrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author fengqq
 * @Description TODO
 * @Date 2024/9/4  16:11
 */
@RestController
@RequestMapping("/orders")
@Api(tags = "订单模块的接口")
@Slf4j
public class OrdersController {

    @Autowired
    private OrdersService ordersService;

    //创建订单
    @ApiOperation("创建订单")
    @GetMapping("/create")
    public Result create(){
        Orders orders = ordersService.create();
        return new Result(200,"订单创建成功",orders);
    }

    //查询订单
    @ApiOperation("查询订单")
    @GetMapping("/findOne/{oid}")
    public Result findOne(@PathVariable("oid") Integer orderId){
        Orders orders = ordersService.findOne(orderId);
        return new Result(200,"订单查询成功",orders);
    }
}
